//先启动http-server.js不要关闭,在启动http-post.js

const http = require("http");
const url = require("url");

var reqUrl = "http://localhost:8080/";
var options = url.parse(reqUrl);
options.method = "POST";

var user = {
    userName:"zhangsan",
    age:20,
    sex:"male"
}
var userStr = JSON.stringify(user);

var request = http.request(options, (res)=>{
    res.pipe(process.stdout);
})

request.write(userStr);
request.end(); //使用request方法最后必须end()

